//Package cmd is a package for parsing command line parameters
//Copyright © 2020 Tim_Paik <timpaik@163.com>
package cmd

import (
	"fmt"
	"strconv"

	"github.com/spf13/cobra"
)

//FullVer : Full version number
const FullVer = "000001"

//IsStable : Whether the package version is the official version
const IsStable = false

//NumVer : Digital version number
var NumVer, _ = strconv.Atoi(FullVer)

//StringVer : String version number
var StringVer = string(FullVer[0]) + "." + string(FullVer[1]) + "." + string(FullVer[2]) + "." + string(FullVer[3]) + string(FullVer[4]) + string(FullVer[5])

// versionCmd represents the version command
var versionCmd = &cobra.Command{
	Use:     "version",
	Short:   "Print the version number of pdk",
	Long:    `Print the version number of pdk`,
	Aliases: []string{"v"},
	Run: func(cmd *cobra.Command, args []string) {
		PrintVersion()
	},
}

func init() {
	rootCmd.AddCommand(versionCmd)

	// Here you will define your flags and configuration settings.

	// Cobra supports Persistent Flags which will work for this command
	// and all subcommands, e.g.:
	// versionCmd.PersistentFlags().String("foo", "", "A help for foo")

	// Cobra supports local flags which will only run when this command
	// is called directly, e.g.:
	// versionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

//PrintVersion : Print version information
func PrintVersion() {
	fmt.Printf(" _____    _ _                                                  \n|  __ \\  | | |     Pdk v%s                              \n| |__) |_| | | __  Copyright © 2020 Tim_Paik <timpaik@163.com> \n|  ___/ _| | |/ /                                              \n| |  | (_| |   <   Redistributed under the terms of GNU GPL.   \n|_|   \\__,_|_|\\_\\                                              \n", StringVer)
}
